<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/jquery-3.5.1.min.js"></script>
</head>
<body>
<form action="/demo02/demo02" method="post">

    <input type="text" name="id">
    <input type="text" name="name">

    <input type="submit">
</form>

<button id="btn">sendRequest</button>

<script>

    $(function () {
        $("#btn").click(function () {

            // Json对象 是表单
            var province = {id: 1, name: "JiLin"}

            $.post({
                url: "/demo02/demo03",
                // ajax默认的提交格式为: application/x-www-form-urlencoded格式是表单
                contentType: "application/x-www-form-urlencoded",
                // contentType: "application/json",
                // data: JSON.stringify(province),//把json对象变成json字符串
                // data: province,
                data:"id=1&name=20",
                success: function (res) {
                    console.log(res);
                }
            })
        })
    })
</script>
</body>
</html>
